/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.udt.generator;

import com.inspur.edp.cef.designtime.api.IGspCommonDataType;
import com.inspur.edp.cef.designtime.api.element.GspElementDataType;
import com.inspur.edp.cef.designtime.api.element.GspElementObjectType;
import com.inspur.edp.cef.entity.dependenceTemp.DataValidator;
import com.inspur.edp.cef.generator.overall.CefGeneratorContext;
import com.inspur.edp.udt.designtime.api.entity.SimpleDataTypeDef;
import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;

public class UdtGeneratorContext extends CefGeneratorContext {

  private UnifiedDataTypeDef udt;

  //private string generatingPath;
  public UdtGeneratorContext(UnifiedDataTypeDef udt) //, string generatingPath
  {
    this.udt = udt;
    //this.generatingPath = generatingPath;

  }

  public UnifiedDataTypeDef getUdt() {
    return udt;
  }

  public GspElementObjectType getSimpleObjType() {
    if (!(getUdt() instanceof SimpleDataTypeDef)) {
      return null;
    }
    return ((SimpleDataTypeDef) getUdt()).getObjectType();
  }
  //public override string ParentNamespace => string.Empty;

  //public override string ParentGeneratePath => string.Empty;

  //public override Dictionary<string, Type> ParentEntityAllInterfaceTypes => new Dictionary<string, Type>();

  //public override Dictionary<string, Type> ParentEntityTypes => new Dictionary<string, Type>();

  //public override string ParentRelativeGeneratePath => string.Empty;
  //public string RelativeGeneratePath { get; internal set; }


  @Override
  public IGspCommonDataType getCommonDataType() {
    return getUdt();
  }

  private String privateRelativeGeneratePath;

  public final String getRelativeGeneratePath() {
    return privateRelativeGeneratePath;
  }

  public final void setRelativeGeneratePath(String value) {
    privateRelativeGeneratePath = value;
  }

  @Override
  public String getDataTypeNamespace() {
    return getUdt().getAssemblyName() + "." + getUdt().getCode().toLowerCase();
  }

  private java.util.HashMap<String, java.lang.Class> privatePersistenceValueReaderTypes = new java.util.HashMap<String, java.lang.Class>();

  public final java.util.HashMap<String, java.lang.Class> getPersistenceValueReaderTypes() {
    return privatePersistenceValueReaderTypes;
  }


  @Override
  public String getGeneratePath() {
    return "";
  }

  //	private java.util.HashMap<String, Assembly> copiedAssembly = new java.util.HashMap<String, Assembly>();
  public final String getCustomActionType(String mdId, String assemblyName, String className) {
    DataValidator.checkForEmptyString(assemblyName, "assemblyName");
    DataValidator.checkForEmptyString(className, "className");

    return className;
  }

  private String privateCoreAssemblyName;

  public final String getCoreAssemblyName() {
    return privateCoreAssemblyName;
  }

  public final void setCoreAssemblyName(String value) {
    privateCoreAssemblyName = value;
  }
}
